﻿#Region "Import"
Imports System.ComponentModel
Imports System.ComponentModel.Design
#End Region

<DefaultEvent("Err"), Designer(GetType(BtnSalirControlDesigner))> _
Public Class BtnSalir
    <Category("Settings"), _
    DescriptionAttribute("Error event handler.")> _
    Public Event Err(ByVal str As String)

    Private _Formulario As DevExpress.XtraEditors.XtraForm
    Public Property Formulario() As DevExpress.XtraEditors.XtraForm
        Get
            Return _Formulario
        End Get
        Set(ByVal Value As DevExpress.XtraEditors.XtraForm)
            _Formulario = Value
        End Set
    End Property

    Private Sub BtnSalir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
        Formulario.Dispose()
    End Sub
End Class

#Region "SmartTag"

Public Class BtnSalirControlDesigner
    Inherits System.Windows.Forms.Design.ControlDesigner

    Private lists As DesignerActionListCollection

    Public Overrides ReadOnly Property ActionLists() _
       As DesignerActionListCollection
        Get
            If lists Is Nothing Then
                lists = New DesignerActionListCollection()
                lists.Add(New BtnSalirControlActionList(Me.Component))
            End If
            Return lists
        End Get
    End Property
End Class

Public Class BtnSalirControlActionList
    Inherits System.ComponentModel.Design.DesignerActionList

    Private MiControl As BtnSalir
    Private designerActionSvc As DesignerActionUIService = Nothing

    Public Sub New(ByVal component As IComponent)
        MyBase.New(component)
        Me.MiControl = component
        Me.designerActionSvc = CType(GetService(GetType(DesignerActionUIService)), DesignerActionUIService)
    End Sub

    Private Function GetPropertyByName(ByVal propName As String) As PropertyDescriptor
        Dim prop As PropertyDescriptor
        prop = TypeDescriptor.GetProperties(MiControl)(propName)

        If prop Is Nothing Then
            Throw New ArgumentException("Propiedad Invalida.", propName)
        Else
            Return prop
        End If
    End Function

    Public Property Formulario() As DevExpress.XtraEditors.XtraForm
        Get
            Return MiControl.Formulario
        End Get
        Set(ByVal value As DevExpress.XtraEditors.XtraForm)
            GetPropertyByName("Formulario").SetValue(MiControl, value)
        End Set
    End Property

    Public Property Text() As String
        Get
            Return MiControl.Text
        End Get
        Set(ByVal value As String)
            GetPropertyByName("Text").SetValue(MiControl, value)
        End Set
    End Property

End Class

#End Region